import QtQuick 1.0
//import ShellInvoker 1.0
import "../../../common/lib/kdeadmouseutils-build-desktop"


ShellInvoker {
   id:perlInvoke
   property string codeMedia
   property string mediaType
   property int progress : 0
   property string location
   
   signal alldone
   signal failedDwnld
   signal startToDwnld
    
   onFinished : {
     console.log('finish wget:' + progress);
   }
   
   onOutputLineChanged : {
	if(!location || location== ''){
	  location=outputLine;
	  return;
	}
	var notYet = (progress==0);//le téléchargementn a pas encore debuté
	if('done'==outputLine){
	  progress=100;
	  if(notYet)
	    startToDwnld();
	  alldone();
	  return;
	}
	if('failed'==outputLine){
	  failedDwnld();
	  return;
	}
	progress = eval(outputLine);
	
	if(notYet && progress>0)
	    startToDwnld();
	
   }
    
    function startDwnld(){
      if(codeMedia && mediaType
	&& codeMedia!= '' && mediaType!= ''){
	progress=0;
	location='';
	console.log('start wget');
	shellAction('/socMDC/KdeadMouse/common/bin/download/grepWget.pl',[mediaType,codeMedia]);
      }
   }
    
}
